package chaoyue.study.reflect;

import chaoyue.study.reflect.bean.Student;

import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

/**
 * 反射属性Field
 */
public class Test05 {
    public static void main(String[] args) throws Exception {
        // 使用反射机制获取Student类中所有的Filed
        Class c = Class.forName("chaoyue.study.reflect.bean.Student");
        // 获取类中所有的public Filed
        for (Field field : c.getFields()) {
            System.out.println(Modifier.toString(field.getModifiers()) + " " + field.getType().getSimpleName() + " " + field.getName());
        }
        System.out.println("-----------------------");
        // 获取类中所有的 Filed
        for (Field field : c.getDeclaredFields()) {
            System.out.println(Modifier.toString(field.getModifiers()) + " " + field.getType().getSimpleName() + " " + field.getName());
        }
    }
}
